class Solution:
    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
        sum = 0
        leng = len(nums) + 1
        start = 0
        for end in range(len(nums)):
            sum += nums[end]
            
            while sum >= target:
                leng = min(leng, end - start + 1)
                if leng == 1:
                    return leng
                sum -= nums[start]
                start += 1
        
        return 0 if leng > len(nums) else leng